using System;
using System.Linq.Expressions;

using TrueCode.Core.Aspects;

namespace TrueCode.Core.Validation
{
  public static class ValidatorExtensions
  {
    public static  void Validate< T >( [NotNull] this IValidator validator, [NotNull] object @object, [NotNull] Expression< Func< T > > property )
    {
      #region Validation
      if( validator == null ) throw new ArgumentNullException( "validator" );
      if( @object == null ) throw new ArgumentNullException( "object" );
      if( property == null ) throw new ArgumentNullException( "property" );
      #endregion

      validator.Validate( @object, nameof.Property( property ) );
    }
  }
}